package com.zhengke.controller.bbfx;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.zhengke.common.object.Result;
import com.zhengke.pojo.MemberStat;
import com.zhengke.service.bbfx.MemberStatService;

/**  

* 创建时间：2020年1月6日 下午3:17:51 

* 项目名称：tvmallbs  

* @author 王东科

* @version 1.0     

* 文件名称：MemberStatController.java  

* 类说明：  

*/
@Controller
@RequestMapping("memberStat/")
public class MemberStatController {

	@Autowired
	private MemberStatService memberStatService; 
	
	/**
	 * 到会员统计页面
	 * @return
	 */
	@RequestMapping("toMemberStat.do")
	public String toMemberStat() {
		return "bbfx/memberStatMgr";
	}
	/**
	 * 到日销量统计页面
	 * @return
	 */
	@RequestMapping("toDayCountOrderMgr.do")
	public String toDayCountOrderMgr() {
		return "bbfx/dayCountOrderMgr";
	}
	
	/**
	 * 查询会员统计信息
	 * @param startTime
	 * @param endTime
	 * @param page
	 * @param limit
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "list.do",method = RequestMethod.POST)
	public Result memberList(String startTime, String endTime, int page, int limit) {
		Result rs = null;
		try {
			rs = memberStatService.queryMember(startTime,endTime, page, limit);
			MemberStat memberStat = memberStatService.queryMemberNum(startTime, endTime);
			Map<String,Object> map = new HashMap<String,Object>();
			map.put("memberStat", memberStat);
			rs.setModel(map);
			return rs;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return new Result();
	}
	@ResponseBody
	@RequestMapping(value = "dayList.do",method = RequestMethod.POST)
	public Result dayCountList(String startTime, String endTime, int page, int limit){
		Result rs = null;
		try {
			rs = memberStatService.queryDayOrder(startTime, endTime, page, limit);
			return rs;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return new Result();
	}
}
